package com.nullpointer.xchat.object;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class SaveStateConfig {
	private String currentChatUserName = null;
	private MainDisplayState mDisplayState = MainDisplayState.ROOM_STATUS;

	public MainDisplayState getmDisplayState() {
		return mDisplayState;
	}

	public String getCurrentChatUserName() {
		return currentChatUserName;
	}

	public void setCurrentChatUserName(String currentChatUserName) {
		this.currentChatUserName = currentChatUserName;
	}

	public void setmDisplayState(MainDisplayState mDisplayState) {
		this.mDisplayState = mDisplayState;
	}

	public String toJson() {
		return new JSONSerializer().exclude("*.class").deepSerialize(this);
	}

	public static SaveStateConfig fromJsonToSaveStateConfig(String json) {
		return new JSONDeserializer<SaveStateConfig>().use(null,
				SaveStateConfig.class).deserialize(json);
	}

	public static String toJsonArray(Collection<User> collection) {
		return new JSONSerializer().exclude("*.class")
				.deepSerialize(collection);
	}

	public static Collection<SaveStateConfig> fromJsonArrayToSaveStateConfigs(
			String json) {
		return new JSONDeserializer<List<SaveStateConfig>>()
				.use(null, ArrayList.class)
				.use("values", SaveStateConfig.class).deserialize(json);
	}
}
